package com.template.mapper;

import com.template.dto.Comment;
import com.template.dto.User;
import org.apache.ibatis.annotations.*;

import java.util.List;
import java.util.Map;

@Mapper
public interface CommentMapper {

//    List<Comment> getCommentByTimeOrGood(@Param("createTime") String createTime, @Param("good") Integer good);

    @Insert("insert into comment(userId,name,imageUrl,likeMan,comment,createTime,good) values (#{userId},#{name},#{imageUrl},#{likeMan},#{comment},#{createTime},#{good})")
    void addComment(Comment comment);

    @Select("select * from comment where id=#{id}")
    Comment getComment(Integer id);

    List<Comment> getCommentByTimeOrGood(Map<String, Object> params);

    @Update("update comment set userId=#{userId},name=#{name},imageUrl=#{imageUrl},likeMan=#{likeMan},comment=#{comment},createTime=#{createTime},good=#{good} where id=#{id}")
    void updateComment(Comment comment);

    @Update("update comment set name=#{name},imageUrl=#{imageUrl} where userId=#{id}")
    void editComment(User user);
}
